module infinity_core:posting_field.impl;

import :posting_field;
import :int_encoder;
import :no_compress_encoder;
import :vbyte_compress_encoder;

namespace infinity {

struct EncoderProvider {
    std::unique_ptr<Int32Encoder> int32_encoder_ = std::make_unique<Int32Encoder>();
    std::unique_ptr<Int16Encoder> int16_encoder_ = std::make_unique<Int16Encoder>();
    std::unique_ptr<NoCompressEncoder> no_compress_encoder_ = std::make_unique<NoCompressEncoder>();
    std::unique_ptr<VByteCompressEncoder> vbyte_compress_encoder_ = std::make_unique<VByteCompressEncoder>();

    static EncoderProvider *GetInstance() {
        static EncoderProvider instance;
        return &instance;
    }

    Int32Encoder *GetInt32Encoder() { return int32_encoder_.get(); }

    Int16Encoder *GetInt16Encoder() { return int16_encoder_.get(); }

    NoCompressEncoder *GetNoCompressEncoder() { return no_compress_encoder_.get(); }

    VByteCompressEncoder *GetVByteCompressEncoder() { return vbyte_compress_encoder_.get(); }
};

const Int32Encoder *GetDocIDEncoder() { return EncoderProvider::GetInstance()->GetInt32Encoder(); }

const Int32Encoder *GetTFEncoder() { return EncoderProvider::GetInstance()->GetInt32Encoder(); }

const Int16Encoder *GetDocPayloadEncoder() { return EncoderProvider::GetInstance()->GetInt16Encoder(); }

const Int16Encoder *GetTermPercentageEncoder() { return EncoderProvider::GetInstance()->GetInt16Encoder(); }

const Int32Encoder *GetSkipListEncoder() { return EncoderProvider::GetInstance()->GetInt32Encoder(); }

const Int32Encoder *GetPosListEncoder() { return EncoderProvider::GetInstance()->GetInt32Encoder(); }

} // namespace infinity